
   
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<script type="text/javascript">
   //删除
function doDeleteDatasource(ids) {
    window.top.$.messager.confirm('提示', '是否确定删除该条记录？', function (b) {
        if (b) {
            $.ajax({
                url: '${pageContext.request.contextPath}/cnbdw/employeeDeviceHistoryAction!delete.action',
                dataType: 'json',
                data: {ids: ids},
                success: function (data) {
                    $.messager.show({title: '提示', msg: data.returnMsg});
                    if (data.returnFlag) {
                        //刷新主列表
                        $('#datagrid11').datagrid('reload');
                    }
                }
            });

        }
    });
}

//批量删除
function doBatchDelete() {
    var rows = $('#datagrid11').datagrid('getChecked')
    if (rows.length <= 0) {
        $.messager.alert('提示', '没有选择任何记录');
    } else {
        var itemIds = [];
        $.each(rows, function (i, item) {
            itemIds.push(item.id);
        });
        $.messager.confirm('删除确认', '是否确定删除选中记录？', function (r) {
            if (r) {
                $.ajax({
                    url: '${pageContext.request.contextPath}/cnbdw/employeeDeviceHistoryAction!delete.action',
                    async: false,
                    data: {ids: itemIds.join(",")},
                    dataType: "json",
                    success: function (result) {
                        $.messager.show({title: '提示', msg: result.returnMsg});
                        if (result.returnFlag) {
                            //刷新主列表
                            $('#datagrid11').datagrid('reload');
                        }
                    }
                });
            }
        });
    }
}

//执行查询
function doQuery() {
    if ($("#datasource_query_form").form("validate")) {
        $("#datagrid11").datagrid('options').queryParams = serializeObject($('#datasource_query_form')); //把查询条件赋值给datagrid内部变量
        $("#datagrid11").datagrid('load'); //重新加载
    }
}
//重置查询条件
function doReset() {
    $('#datasource_query_form').form('reset');
    
        $("#datagrid11").datagrid('load'); //重新加载
    
}
//页面加载完后响应 onReady
$(function () {
//var empId="${empId}";

 var emp=$("#emp").val();
// alert(emp+"!!!");
  var device=$("#device").val();
  
  if(emp==null||emp==""){
 
   $("#empn").show();
   $("#empv").show();
  }
   if(device==null||device==""){
 $("#devicen").show();
   $("#devicev").show();
  }
  
    //查询按纽绑定事件
    $('#btnQuery1').bind('click', doQuery);
    //重置按纽绑定事件
    $('#btnReset1').bind('click', doReset);
   // alert("111qqq");
    //初始化主列表
    $('#datagrid11').datagrid({
        url: '${pageContext.request.contextPath}/cnbdw/employeeDeviceHistoryAction!getAllDatasourceList.action?emp='+emp+'&device='+device,
        fit: true,
        border: false,
        fitColumns: true,
        pagination: true,
        pageList: [30],
        rownumbers: true,
        sortName: 'id',
        sortOrder: 'desc',
        striped: true,
        columns: [
            [
               
                {field: 'empId', title: '姓名', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'devId', title: '设备名', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'recordTime', title: '绑定时间', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'logoffTime', title: '解绑时间', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'offReason', title: '退绑原因', align: 'left', formatter: function (value, rowData, rowIndex) {if (value == '') {return '--'} return value;}},
                {field: 'action', title: '操作', align: 'right',
                    formatter: function (value, row, index) {
                        var html = "";
                       
                       
                        html += '<span style="cursor:pointer" onclick="doDeleteDatasource(\'' + row.id + '\')"><img src="${pageContext.request.contextPath}/images/icons/delete.png" title="删除" alt="删除" style="margin-top:2px;">删除&nbsp;&nbsp;</span>';
                        
                        return html;
                    }
                }
            ]
        ]
       
    });
});


</script>

<input type="hidden" id="emp" value="${emp}" />
<input type="hidden" id="device" value="${device}" />
        
       <form id="datasource_query_form" method="post">
   
        <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
            <tr>
                <td style="width:1%;text-align:left; display:none;" nowrap="nowrap" id="empn" >
                    <label for="datasource_datsourcename">姓名：</label>
                </td>
                <td style="width:15%;text-align:left;display:none;" nowrap="nowrap" id="empv">
                    <input type="text" id="datasource_datsourcename" name="empId" class="easyui-validatebox"
                           data-options="validType:'specialCharFilter'"/>
                </td>
                 <td style="width:1%;text-align:left;display:none;" nowrap="nowrap" id="devicen">
                    <label for="datasource_datsourcename">设备名称：</label>
                </td>
                <td style="width:15%;text-align:left;display:none;" nowrap="nowrap" id="devicev">
                    <input type="text" id="datasource_datsourcename" name="devId" class="easyui-validatebox"
                           data-options="validType:'specialCharFilter'"/>
                </td>
                <td colspan="2" style="width:25%;text-align:right;" nowrap="nowrap">
                    <input type="button" id="btnQuery1" value="查 询" class="search_btn"/>
                    <input type="button" id="btnReset1" value="重 置" class="reset_btn"/>
                </td>
            </tr>
        </table>
    
   
</form>
   

<table id="datagrid11"></table>



